package com.lj.job.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lj.common_web.annotation.ResponseResultVo;
import com.lj.common_web.utils.ServletUtil;
import com.lj.job.param.JobLogPageParam;
import com.lj.job.result.JobLogPageResult;
import com.lj.job.service.JobLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * <p>
 * 定时任务日志 前端控制器
 * </p>
 *
 * @author luojing
 * @since 2025-03-20 15:26:16
 */
@RestController
@RequestMapping("/job/log")
@ResponseResultVo
@Tag(name = "定时任务日志 管理")
public class JobLogController {

    @Resource
    private JobLogService jobLogService;

    @GetMapping("/page")
    @SaCheckPermission("job:log:list")
    @Operation(summary = "定时任务日志 分页查询")
    public IPage<JobLogPageResult> page(@ParameterObject JobLogPageParam param) {
        return jobLogService.page(param);
    }

    @GetMapping("/export/excel")
    @SaCheckPermission("job:log:export")
    @Operation(summary = "定时任务日志 excel导出")
    public void exportExcel(@ParameterObject JobLogPageParam param) throws IOException {
        ServletUtil.download("定时任务日志-导出数据.xlsx",
                outputStream -> jobLogService.exportExcel(param, outputStream));
    }

}

